public class Enum {
    public static void main(String[] args) {
        EnumerateClasses enumerateClasses = EnumerateClasses.X;
        enumerateClasses.fun();

        System.out.println(enumerateClasses.getName());
        System.out.println(enumerateClasses.getAge());

        //该方法可以得到全部对象，并且放到一个数组中
        EnumerateClasses[] e = EnumerateClasses.values();
        for (int i = 0; i < e.length; i++) {
            EnumerateClasses j = e[i];
            System.out.print(j.getName()+" ");
            System.out.println(j.getAge());
        }

        System.out.println("-----------------------------------------");
        //该方法可以得到指定的对象
        EnumerateClasses name = EnumerateClasses.valueOf("X");
        System.out.print(name.getName() + " ");
        System.out.println(name.getAge());
        //该方法可以得到该对象对应的索引
        System.out.println(name.ordinal());
    }
}
enum EnumerateClasses{
    X("李四",12),Y("王五",22),Z("张三",33);

    private String name;
    private int age;

    public void fun(){
        System.out.println("调用枚举类中的方法");
    }

    EnumerateClasses() {
    }

    EnumerateClasses(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}